#!/usr/bin/env python3  /*设定脚本文件直接能执行*/
# -*- coding:utf-8 -*-   /*设置编码*/
"""
@Author: WANDERSON M.PIMENTA
@Software: PyCharm 、Qt Designer and PySide6
@File: tQLineEdit.py
@Time: 2024/05/11 16:35
@Function：ctQLineEdit：自定义的文本编辑框
"""
from tQQtCore import *

# 样式表
style = '''
QLineEdit {{
	background-color: {_bg_color};
	border-radius: {_radius}px;
	border: {_border_size}px solid transparent;
	padding-left: 10px;
    padding-right: 10px;
	selection-color: {_selection_color};
	selection-background-color: {_context_color};
    color: {_color};
}}
QLineEdit:focus {{
	border: {_border_size}px solid {_context_color};
    background-color: {_bg_color_active};
}}
'''


# QLineEdit
class ctQLineEdit(QLineEdit):
    def __init__(self,
                 text="",
                 place_holder_text="",
                 radius=8,
                 border_size=2,
                 color="#FFF",
                 selection_color="#FFF",
                 bg_color="#333",
                 bg_color_active="#222",
                 context_color="#00ABE8"):
        super().__init__()

        # 参数设置
        if text:
            self.setText(text)
        if place_holder_text:
            self.setPlaceholderText(place_holder_text)

        # 设置样式表
        self.__f_setStylesheet(radius, border_size, color, selection_color, bg_color, bg_color_active, context_color)

    # 设置样式表
    def __f_setStylesheet(self,
                          radius,
                          border_size,
                          color,
                          selection_color,
                          bg_color,
                          bg_color_active,
                          context_color):
        # 应用样式
        style_format = style.format(_radius=radius, _border_size=border_size, _color=color,
                                    _selection_color=selection_color, _bg_color=bg_color,
                                    _bg_color_active=bg_color_active, _context_color=context_color)
        self.setStyleSheet(style_format)
